package web.blogsphere.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import web.blogsphere.model.BlogInfo;

import java.util.List;

/**
 * @ClassName BlogMapper
 * @Description TODO
 * @Author ZJX
 * @Date 2024/9/3 20:55
 * @Version 1.0
 */
@Mapper
public interface BlogMapper {

//    返回博客列表
    @Select("select * from blog where delete_flag = 0")
    List<BlogInfo> selectAll();

//    根据博客id返回博客
    @Select("select * from blog where id =#{id}")
    BlogInfo selectById(Integer id);


//    更新博客  更新+删除原来博客 使用xml方式实现
    Integer updateBlog(BlogInfo blogInfo);

//    发布博客
    @Insert("insert into blog (title, content, user_id) values (#{title}, #{content}, #{userId})")
    Integer insertBlog(BlogInfo blogInfo);
}
